import Buff from '@/Buff';
import BuffUtil from '@/BuffUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 放血
 **/
export default class DZ_LetBlood extends AbilityBase {
    static instance: DZ_LetBlood;
    buffType: AppBuffType = {
        id: 'buff_DZ_LetBlood',
        art: this.art,
        name: this.abilityName,
        ubertip: '',
        interval: 0.5,
        onInterval: this.buffInterval.bind(this),
        dur: 12,
    };
    buffInterval(buff: Buff) {
        let lv = this.getAbilityLevel(buff.getCaster());
        let dmg = 30 * lv + UnitCommon.取固定攻击(buff.getCaster()) * (0.55 * lv);
        DamageSystemInstance.applyPhysicalDamage(buff.getParent(), buff.getCaster(), dmg / 2, this.id, true);
        DestroyEffect(AddSpecialEffectTarget('Objects\\Spawnmodels\\Other\\BeastmasterBlood\\BeastmasterBlood.mdl', buff.getParent(), 'origin'));
    }
    constructor(id: string = 'Afx1') {
        super(id);
        DZ_LetBlood.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        DamageSystemInstance.applyAttackDamage(target, source, UnitCommon.取攻击(source), this.id);
        // BuffUtil.addBuff(target, this.buffType.id, source);
        BuffCommon.addBuff({ target, caster: source, buffTypeId: this.buffType.id, ablityId: this.id });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
